﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using GPS.DAL;
using GPS.MODELS;
using System.Data.SqlClient;
using System.Timers;
using System.Data;
using System.Data.Entity;
using Microsoft.AspNet.Identity;
using GPS.DataAccessLayer;
using GPS.COMMON;


namespace GPS.Controllers
{
    public class GPS_TrackingOnlineController : Controller
    {
        DbContextHelper<GPS_NVContext> _db = Singleton<DbContextHelper<GPS_NVContext>>.Inst;
        public ApplicationUser getCurrentUser()
        {
            ApplicationDbContext dbUser = new ApplicationDbContext();

            string userId = User.Identity.GetUserId();

            ApplicationUser _currentUser = dbUser.Users.Find(userId);

            return _currentUser;
        }
        public ActionResult Index()
        {
            ////ApplicationUser curUser = getCurrentUser();
            ////count so giay phep het han
            //string DVGTVT_MA = this.getCurrentUser().MA_TINHTP;

            //return Redirect("http://localhost:50772/GPS_GiamSatHanhTrinh/Index?p=" + DVGTVT_MA);

            //ApplicationUser curUser = getCurrentUser();
            //count so giay phep het han
            string DVGTVT_MA = this.getCurrentUser().MA_TINHTP;
            ViewBag.DVGTVT_MA = DVGTVT_MA;
            return View(); //Redirect("http://localhost:50772/GPS_GiamSatHanhTrinh/Index?p=" + DVGTVT_MA);
        }

        //public ApplicationUser getCurrentUser()
        //{
        //    ApplicationDbContext dbUser = new ApplicationDbContext();

        //    string userId = User.Identity.GetUserId();

        //    ApplicationUser _currentUser = db.Users.Find(userId);

        //    return _currentUser;
        //}

        //public ActionResult Denied()
        //{
        //    return View();
        //}


        protected override void Dispose(bool disposing)
        {
            //db.Dispose();
            //base.Dispose(disposing);
        }
	}
}